"""
@name : 用户名密码复杂度验证
@author : shiyaling
@projectname : xsfh
"""

#判断是否包括大、小写字母、数字、其他符号以上四种至少三种
def passwd_type(passwd,grade):
    result = [0,0,0,0]
    for i in passwd:
        if i.isupper():
            result[0] = 1
        elif i.islower():
            result[1] = 1
        elif i.isdigit():
            result[2] = 1
        else:
            result[3] = 1
    if sum(result) >= 3:
        grade += 1
    else:
        change.append("密码没有由3种以上字符组成 ")
    return grade

#判断是否有长度超过或等于3的子串重复
def passwd_repeat(passwd,grade):
    grade_repeat = 0
    for i in range(len(passwd)):
        if passwd.count(passwd[i:i+3]) >= 2:
            grade_repeat += 1
    if grade_repeat == 0:
        grade += 1
    else:
        change.append("密码有长度超过或等于3的子串重复 ")
    return grade




passwd = input("请输入你要测试的密码：")
change = []
grade = 2
#判断长度是否超过8位
if len(passwd) >= 8:
    grade += 1
else:
    change.append("长度少于8位 ")
grade = passwd_type(passwd,grade)
grade = passwd_repeat(passwd,grade)
if grade == 5:
    change.append("密码复杂度为5，无需改进")
print(grade,change)







